﻿/*
 *   GlobalExtensions.cs
 *   Copyright (c) 2011 - BitFox Software and Ricardo Federico Villafañes
 *   Contact: federvillaf@hotmail.com
 *   
 *   Licensing: This product is covered by Microsoft Reciprocal License (MS-RL)
 *              see https://bitfoxeval.codeplex.com/license
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;

namespace BitFox
{
    /// <summary>
    /// Common extensions...
    /// </summary>
    static class GlobalExtensions
    {
        public static int FoxCompare(this string src, string target, bool ignoreCase)
        {
            return string.Compare(
                src, 
                target, 
                ignoreCase? 
                    StringComparison.InvariantCultureIgnoreCase :
                    StringComparison.InvariantCulture);
        }

        public static string FoxToUpper(this string src)
        {
            return src.ToUpperInvariant();
        }

        [SuppressMessage("Microsoft.Globalization", "CA1308")]
        public static string FoxToLower(this string src)
        {
            return src.ToLowerInvariant();
        }

        public static string FoxToString(this int src)
        {
            return src.ToString(CultureInfo.InvariantCulture);
        }

        public static string FoxToString(this char src)
        {
            return src.ToString(CultureInfo.InvariantCulture);
        }

        public static string FoxToString(this decimal src)
        {
            return src.ToString(CultureInfo.InvariantCulture);
        }
    }
}
